home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / cuserid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  637 b   |  44 lines

  1. #include "lib.h"
  2.  
  3. /*  cuserid(3)
  4.  *
  5.  *  Author: Terrence W. Holm          Sept. 1987
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <pwd.h>
  10.  
  11. #ifndef  L_cuserid
  12. #define  L_cuserid   9
  13. #endif
  14.  
  15. #ifdef __STDC__
  16. extern struct passwd *getpwuid(int);
  17. #else
  18. extern struct passwd *getpwuid();
  19. #endif
  20.  
  21.  
  22. char *cuserid( user_name )
  23.   char *user_name;
  24.  
  25.   {
  26.   static  char   userid[ L_cuserid ];
  27.   struct passwd *pw_entry;
  28.  
  29.   if ( user_name == NULL )
  30.     user_name = userid;
  31.  
  32.   pw_entry = getpwuid( geteuid() );
  33.  
  34.   if ( pw_entry == NULL )
  35.     {
  36.     *user_name = '\0';
  37.     return( NULL );
  38.     }
  39.  
  40.   strcpy( user_name, pw_entry->pw_name );
  41.  
  42.   return( user_name );
  43.   }
  44.